const path = require('path')
const px2rem = require("postcss-plugin-px2rem")

function resolve(dir) {
    return path.join(__dirname, dir)
}

const px2remOptions = {
  rootValue: 19.2,
  unitPrecision: 5,
  mediaQuery: false,
  minPixelValue: 0,
};

module.exports = {
    chainWebpack: config => {
        // 路径别名
        config.resolve.alias.set('@', resolve('src'))
    },
    // 配置scss文件
    css: {
      loaderOptions: {
        sass: {
          prependData: `@import "@/assets/css/black.scss";`
        },
        postcss: {
          plugins: [px2rem(px2remOptions)],
        },
      }
    },
    // 代理配置
    devServer: {
      open: false,
      proxy: {
        '/dashen': {
          // target: "http://v2440e7437.wicp.vip",
          // target: "http://47.96.122.11:12377",
          target: process.env.VUE_APP_URL,
          ws: true,
          changeOrigin: true,
          pathRewrite:{
            '^/dashen':''
        }
        }
      }
    }
}
